package org.springframework.batch.admin.sample.readers;

import org.springframework.batch.item.ItemReader;
import org.springframework.batch.item.ParseException;
import org.springframework.batch.item.UnexpectedInputException;

public class DayEndItemReader implements ItemReader<String> {

	private String inputValue;

	public String getInputValue() {
		return inputValue;
	}

	public void setInputValue(String inputValue) {
		this.inputValue = inputValue;
	}

	private static final int MAX_OUTER = 0;

	private String[] input = new String[] {getInputValue()};

	private int index = 0;

	private int outer = 0;

	/**
	 * Reads next record from input
	 */
	public synchronized String read() throws Exception {
		if (index >= input.length) {
			outer++;
			if (outer > MAX_OUTER) {
				return null;
			} else {
				index = 0;
			}
		}
		return input[index++];
	}

}
